Skip to content

Allow students to view the preview projects - #974

Open
DNR500 wants to merge 2 commits into
mainfrom
allow-students-to-view-preview-projects
Open

Allow students to view the preview projects#974
DNR500 wants to merge 2 commits into
mainfrom
allow-students-to-view-preview-projects

Conversation

@DNR500

@DNR500 DNR500 commented Aug 19, 2026

Copy link
Copy Markdown
Contributor

Needs to allow student view checks on issue: 1659

Comes out of this work on editor-standalone - https://github.com/RaspberryPiFoundation/editor-standalone/pull/1064

Summary

Updated editor-api CanCan permissions so that school students can :show the Experience CS preview starter project used by the classroom preview route.

With this changes students are now allowed to view unowned (user_id: nil, school_id: nil) Scratch template projects.

This prevents the preview route in editor-standalone from failing project loading (which previously triggered a redirect to /${locale}/error).

@cla-bot cla-bot Bot added the cla-signed label Aug 19, 2026
@DNR500
DNR500 requested a lite review from Copilot August 19, 2026 15:38
@DNR500 DNR500 self-assigned this Aug 19, 2026
@github-actions

github-actions Bot commented Aug 19, 2026

Copy link
Copy Markdown

Test coverage

93.34% line coverage reported by SimpleCov.
Run: https://github.com/RaspberryPiFoundation/editor-api/actions/runs/32274729383

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Updates CanCanCan authorization in the Rails monolith to allow school students to access the unowned Experience CS preview starter project (and related data) so the editor-standalone classroom preview route can load the project successfully.

Changes:

  • Adds a student-specific :show permission for unowned Projects of type Project::Types::CODE_EDITOR_SCRATCH.
  • Adds a corresponding student-specific :show permission for Components belonging to those unowned scratch projects.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread app/models/ability.rb
@DNR500
DNR500 marked this pull request as ready for review August 19, 2026 16:33
Comment thread app/models/ability.rb
can :show, Project, user_id: nil, school_id: nil, project_type: Project::Types::CODE_EDITOR_SCRATCH
can :show, Component, project: { user_id: nil, school_id: nil, project_type: Project::Types::CODE_EDITOR_SCRATCH }
return
end

@zetter-rpf zetter-rpf Aug 24, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the placement of these rules aren't quite right because they are in the non_student_abilities method but apply to students.

If these projects should be visible to everyone (which I think is the case), then they should be here without the if user&.student? check

If these projects should be visible by student (but not the general public) then they should live in a define_school_student_abilities method, or a more general define_school_student_global_abilities method since these abilities aren't specific to a school like the others are.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've just seen the rules below which I missed before. Is it important we restrict students from seeing other public projects (which they can presumably see anyway if they sign out?). If not, maybe this could be solved by removing the return if user&.student? return and renaming define_common_non_student_abilities to define_common_abilities

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants